<template>
    <div class="photoinfo-container">
        <h2>{{photoinfo.title}}</h2>
        <p class="photoinfo-two">
            <span>时间:{{photoinfo.add_time|dateFormat}}</span>
            <span>点击{{photoinfo.click}}次</span>
        </p>
        <hr>
        <!-- 缩略图区域 -->
<div class="thumbs">
     <vue-preview :slides="slide1" @close="handleClose"></vue-preview>
</div>
        <!-- 图片内容区域 -->
        <div class="conent" v-html="photoinfo.content"></div>
       <cmt-box :id=this.id></cmt-box>
    </div>
</template>
<script>
import {Toast} from 'mint-ui'
import comment from '../subcompoments/comment.vue' 
export default {
     data(){
        return{
            id:this.$route.params.id,
            photoinfo:{},
            slide1: []
        }
    },
    created(){
        this.getphotoinfo();
        this.getThumbs() ;   
    },
    methods:{
        getphotoinfo(){
            this.$http.get('api/getimageInfo/'+this.id).then(result=>{
                if(result.body.status==0){
                    this.photoinfo=result.body.message[0];
                }
                else{
                    Toast('加载失败')
                }
            })
        },
      getThumbs() {
                // 获取缩略图
                this.$http.get('api/getthumimages/'+this.id)
                    .then(response => {
          //循环每个图片数据,补全图片的宽和高
          response.data.message.forEach(item => {
            item.msrc = item.src;
            item.w = 600;
            item.h = 400;
          });
          this.slide1 = response.data.message;
          console.log(this.slide1);
        })
        .catch(error => {
          console.log(error);
          Toast({
            message: "获取缩略图图片失败..."
          });
        });
    },
    handleClose() {
      console.log("close event");
    }
  },
       components:{
        'cmt-box':comment
    }
}
</script>

<style lang="scss" scoped>
.photoinfo-two{
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}
.photoinfo-container{
    padding: 3px;
}
.photoinfo-container h2{
    font-size: 15px;
    color: #26a2ff;
    text-align: center;
    margin: 15px;
}
.conent{
    font-size: 13px;
    line-height: 30px;
}
hr{
    color: rgb(192, 193, 194)
}
.thumbs {
            /deep/ .my-gallery{   //deep深层作用选择器
                display: flex;
                flex-wrap:wrap;//默认换行
                figure{
                    width: 30%;
                    margin: 5px;
                    img{
                        width: 100%;
                        box-shadow: 0 0 8px #999;
                        border-radius: 5px;
                        
                    }
                }
            }
        }
</style>
